<?php
$Task_name =$_POST['task_name'] ?? '';
$Explanation =$_POST['explanation'] ?? '';

// 把班级信息存储到数据库
$dsn = "sqlsrv:Server=localhost;Database=Task";
$db = new PDO($dsn, "sa", "123456");

$sql = "insert into Task (TaskName,TaskContent) values('{$Task_name}','{$Explanation}') ";
$result = $db->exec($sql);
if ($result) {
    echo '增加成功，前往<a href="list.php">任务列表页</a>';
} else {
    echo '添加失败';
}